/*****************************************************************
 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work
 * for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations
 * under the License.
 ****************************************************************/
package reco.db.field;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Date;

import reco.db.ConstraintFactory;
import reco.db.Domain;

/**
 * Defines static method factories for predefined types
 */
public final class Fields {

    /**
     * Avoids the construction of {@link Fields} class instances.
     */
    private Fields() {
        throw new UnsupportedOperationException("you should not try to create instances of this class");
    }

    public static <D extends Domain<D>> BooleanField<D> newBoolean(ConstraintFactory... fieldConstraintsDefinitions) {
        return new BooleanField<D>(fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> StringField<D> newString(ConstraintFactory... fieldConstraintsDefinitions) {
        return new StringField<D>(fieldConstraintsDefinitions);
    }

    public static <E extends Enum<E>, D extends Domain<D>> EnumField<E, D> newEnum(Class<E> enumeration,
                    ConstraintFactory... fieldConstraintsDefinitions) {
        return new EnumField<E, D>(enumeration, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> NumberField<BigDecimal, D> newBigDecimal(ConstraintFactory... fieldConstraintsDefinitions) {
        return new NumberField<BigDecimal, D>(BigDecimal.class, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> NumberField<BigInteger, D> newBigInteger(ConstraintFactory... fieldConstraintsDefinitions) {
        return new NumberField<BigInteger, D>(BigInteger.class, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> NumberField<Byte, D> newByte(ConstraintFactory... fieldConstraintsDefinitions) {
        return new NumberField<Byte, D>(Byte.class, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> NumberField<Double, D> newDouble(ConstraintFactory... fieldConstraintsDefinitions) {
        return new NumberField<Double, D>(Double.class, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> NumberField<Float, D> newFloat(ConstraintFactory... fieldConstraintsDefinitions) {
        return new NumberField<Float, D>(Float.class, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> NumberField<Integer, D> newInteger(ConstraintFactory... fieldConstraintsDefinitions) {
        return new NumberField<Integer, D>(Integer.class, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> NumberField<Long, D> newLong(ConstraintFactory... fieldConstraintsDefinitions) {
        return new NumberField<Long, D>(Long.class, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> NumberField<Short, D> newShort(ConstraintFactory... fieldConstraintsDefinitions) {
        return new NumberField<Short, D>(Short.class, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> DateField<Date, D> newDate(ConstraintFactory... fieldConstraintsDefinitions) {
        return new DateField<Date, D>(Date.class, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> DateField<java.sql.Date, D> newDay(ConstraintFactory... fieldConstraintsDefinitions) {
        return new DateField<java.sql.Date, D>(java.sql.Date.class, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> DateField<Time, D> newTime(ConstraintFactory... fieldConstraintsDefinitions) {
        return new DateField<Time, D>(Time.class, fieldConstraintsDefinitions);
    }

    public static <D extends Domain<D>> DateField<Timestamp, D> newTimestamp(ConstraintFactory... fieldConstraintsDefinitions) {
        return new DateField<Timestamp, D>(Timestamp.class, fieldConstraintsDefinitions);
    }
}
